<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>智能订餐</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/style.css">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/layer.css">
</head>
<body>
<div class="wraper">

    <div class="min-height">
        <div class="header flex_between font-white">
            <a href="/Base/Inforschool/Index2" class="iconfont icon-left font-white"></a>
            <div class="font-16">用餐人员</div>
            <a href="/Base/Inforschool/addPeople?ftype={BEESCRM:$condition}"
               class="iconfont icon-tianjia font-white"></a>
        </div>
        <form action="/Base/Inforschool/diners" method="post" id='frm'>
            <div class="search flex_between">
                <input class="search_input font-12" type="text" name="yname" placeholder="请输入关键字"
                       value="{BEESCRM:$yname}">
                <input type="hidden" name="ftype" value="{BEESCRM:$condition}">
                <input type="submit" value="查找" class="hide js_submit">
                <div class="iconfont icon-sousuo font-white text-center"></div>
            </div>
        </form>
        <div>
            <input type="hidden" id="condition" value="{BEESCRM:$condition}">
            <if condition="$condition eq 1">
                <div class="bg_white ">
                    <div class="boxs flex_between js_all">
                        <div class="js_check margin-l20">
                            <span class="iconfont icon-xuanze1 checkbox"></span>
                            <span>学生</span>
                        </div>
                        <div class="number_of_people margin-r20">
                            {BEESCRM:$count1}人
                        </div>
                    </div>
                    <div class="boxs boxs2 clearfix js_table" id="student">
                        <volist name="data1" id="v">
                            <div class="name pull-left margin-l20" data-id="{BEESCRM:$v['ycuser_id']}">
                                <span class="iconfont icon-xuanze1 checkbox"></span>
                                <span>{BEESCRM:$v['yname']}</span>
                            </div>
                        </volist>
                    </div>
                </div>
                <div class="bg_white margin-12">
                    <div class=" boxs flex_between js_all">
                        <div class="js_check margin-l20">
                            <span class="iconfont icon-xuanze1 checkbox"></span>
                            <span>教职工</span>
                        </div>
                        <div class="number_of_people margin-r20">
                            {BEESCRM:$count2}人
                        </div>
                    </div>
                    <div class=" boxs boxs2 clearfix js_table" id="teacher">
                        <volist name="data2" id="v">
                            <div class="name pull-left margin-l20" data-id="{BEESCRM:$v['ycuser_id']}">
                                <span class="iconfont icon-xuanze1 checkbox"></span>
                                <span>{BEESCRM:$v['yname']}</span>
                            </div>
                        </volist>
                    </div>
                </div>

            </if>
            <!-- 在接待中才会显示以下模块-->
            <if condition="$condition neq 1">
                <div class="bg_white">
                    <div class="boxs flex_between js_all">
                        <div class="js_check margin-l20">
                            <span class="iconfont icon-xuanze1 checkbox"></span>
                            <span>来宾</span>
                        </div>
                        <div class="number_of_people margin-r20">
                            {BEESCRM:$count3}人
                        </div>
                    </div>
                    <div class="boxs boxs2 clearfix js_table">
                        <volist name="data3" id="v">
                            <div class="name pull-left margin-l20" data-id="{BEESCRM:$v['ycuser_id']}">
                                <span class="iconfont icon-xuanze1 checkbox"></span>
                                <span>{BEESCRM:$v['yname']}</span>
                            </div>
                        </volist>
                    </div>
                </div>
            </if>
        </div>
        <a href="#" class="btn btn2 font-16 text-center">下一步</a>
    </div>
</body>
<script src="/assets/base/Inforschool/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/Inforschool/js/layer.js"></script>
<script src="/assets/base/Inforschool/js/public.js"></script>
<script>
    var height = $(window).height();
    $('.wraper').css('minHeight', height);
    var btn_height = $('.btn').innerHeight();
    $('.min-height').css('height', height - btn_height);


    //全选
    $('.js_all').on('click', '.js_check', function () {
        var $this = $(this).children('.iconfont');
        if ($this.hasClass('icon-xuanze1')) {
            $this.removeClass('icon-xuanze1').addClass('icon-xuanze');
            $(this).parents('.js_all').siblings('.js_table').find('.iconfont').removeClass('icon-xuanze1').addClass('icon-xuanze');
        }
        else {
            $this.removeClass('icon-xuanze').addClass('icon-xuanze1');
            $(this).parents('.js_all').siblings('.js_table').find('.iconfont').removeClass('icon-xuanze').addClass('icon-xuanze1');
        }
    });
    //半选
    $('.js_table').on('click', '.name', function () {
        var $this = $(this).children('.iconfont');

        if ($this.hasClass('icon-xuanze1')) {
            $this.removeClass('icon-xuanze1').addClass('icon-xuanze');
        }
        else {
            $this.removeClass('icon-xuanze').addClass('icon-xuanze1');
        }
        var lenght = $(this).parents('.js_table').find('.icon-xuanze1').length;


        if (lenght <= 0) {
            $(this).parents('.js_table').siblings('.js_all').find('.iconfont').removeClass('icon-xuanze1').addClass('icon-xuanze');
        }
        else {
            $(this).parents('.js_table').siblings('.js_all').find('.iconfont').removeClass('icon-xuanze').addClass('icon-xuanze1');

        }
    })

/*    $('.bg_white').on('click', '.name,.js_check', function () {
        $('.js_table').each(function () {
            var $this = $(this).find('.iconfont');
            if ($this.hasClass('icon-xuanze')) {
                var id = $(this).attr("id");
                console.log(id);
                if (id == 'student') {
                    console.log('1')
                } else if (id == 'teacher') {
                    console.log('2');
                }
            }
        })
    })*/

    $('.icon-sousuo').click(function () {
        $('.js_submit').click();
    })

    $(document).on('click', '.btn', function () {
        //获取全部选择的id
        var ID = new Array();
        var condition = $('#condition').val();
        $('.name .icon-xuanze').each(function () {
            ID.push($.trim($(this).parents('.name').data('id')));
        });

        if (ID == '') {
            fm.alert('请选择用餐人员！');
            return false;
        }
        var data = {};
        data.ID = ID;
        var icon_ID=[];
         $('.js_table').each(function () {
            var $this = $(this).find('.iconfont');
            if ($this.hasClass('icon-xuanze')) {
                var id = $(this).attr("id");
                if (id == 'student') {
                    icon_ID.push('1');
                } else if (id == 'teacher') {
                    icon_ID.push('2');
                }
            }
        })
        
          var leng=icon_ID.length;
          var status;
          if (leng==2) {
            status = '3';
          }else if(leng==1&&icon_ID=='1'){
            status = '1';
          }else if(leng==1&&icon_ID=='2'){
            status = '2';
          }
        data.status = status;
        data.condition = condition;
        $.ajax({
            'url': "/base/Inforschool/foodSelect",
            'data': data,
            'dataType': 'json',
            'type': 'POST',
            success: function (data) {
                if (data.status == 'S') {
                    setTimeout("reload('" + data.url + "')", 1000);
                } else {
                    return false;
                }
            }
        })
    })
    function reload(url) {
        location.href = url;
    }


</script>
</html>